<template>
  <div>
      <input type="text"  v-model="inputval">
      <button :disabled="bool" ref="b1">检测watch</button>
      {{inputval}}
      <!-- {{newtext}} -->
  </div>
</template>

<script>
export default {
    data(){
        return{
            bool:true,
            inputval:'',
        }
    },
    watch:{
        inputval(){
            if(this.inputval==''){
                this.bool=true
                this.$refs.b1.style.background="red"
            }else{
                this.bool=false
                this.$refs.b1.style.background="green"
            }
        }
    },
    mounted(){
          this.$refs.b1.style.background="red"
    }
}
</script>

<style>

</style>